Skip to content

Java: make a separate threat model kind for reverse DNS sources #16760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

owen-mc
Copy link
Contributor

@owen-mc owen-mc commented Jun 14, 2024

I'm new to threat models, so I may be missing something that is required. In particular, is it okay to have a threat model kind that isn't part of the hierarchy controlled by this file?

Also, I searched for other reverse DNS sources and only found this one in C#, which seems to be only be used in one query currently. Any opinion on whether that should be made a source that applies to all queries and added to this new threat model kind? (I think this should be follow-up work.)

@owen-mc owen-mc requested a review from a team as a code owner June 14, 2024 12:41
@owen-mc owen-mc force-pushed the java/reverse-dns-separate-threat-model-kind branch from 98d91a2 to f5456b6 Compare June 14, 2024 14:48
@owen-mc owen-mc force-pushed the java/reverse-dns-separate-threat-model-kind branch from becc25c to c0172a2 Compare June 22, 2024 20:52
Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks generally good (with one suggestion). I looked at the threat model part of this. Someone more familiar with the ql should review the rest.

@owen-mc owen-mc force-pushed the java/reverse-dns-separate-threat-model-kind branch from e2132ad to 9874bc1 Compare June 24, 2024 11:37
@owen-mc owen-mc force-pushed the java/reverse-dns-separate-threat-model-kind branch from 9874bc1 to 8458bde Compare June 24, 2024 20:24
aeisenberg
aeisenberg previously approved these changes Jul 8, 2024
Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for updating the documentation.


The less commonly used categories are:

- ``android`` which represents reads from external files in Android (``android-external-storage-dir``) and parameter of an entry-point method declared in a ``ContentProvider`` class (``contentprovider``).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this is kotlin only (though maybe Java as well?).

Suggested change
- ``android`` which represents reads from external files in Android (``android-external-storage-dir``) and parameter of an entry-point method declared in a ``ContentProvider`` class (``contentprovider``).
- ``android`` which represents reads from external files in Android (``android-external-storage-dir``) and parameter of an entry-point method declared in a ``ContentProvider`` class (``contentprovider``). Currently only used by Kotlin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kind of hard to tell, but at least one of the tests for this is written in java. I'll put "Java/Kotlin".

Comment on lines 15 to 17
- ``database-access-result`` which represents a database access (currently only used by javascript).
- ``file-write`` which represents opening a file in write mode (currently only used in C#).
- ``reverse-dns`` which represents reverse DNS lookups (currently only used in java).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor copy-editing:

Suggested change
- ``database-access-result`` which represents a database access (currently only used by javascript).
- ``file-write`` which represents opening a file in write mode (currently only used in C#).
- ``reverse-dns`` which represents reverse DNS lookups (currently only used in java).
- ``database-access-result`` which represents a database access. Currently only used by JavaScript.
- ``file-write`` which represents opening a file in write mode. Currently only used in C#.
- ``reverse-dns`` which represents reverse DNS lookups. Currently only used in Java.

@owen-mc
Copy link
Contributor Author

owen-mc commented Jul 8, 2024

@aeisenberg Thanks. Note that windows-registry is currently only used by C#. Any suggestion for how to shoe-horn that info in? Also, I might well make a reverse-dns source for C# after this PR is merged - I assume that I should then remove the " Currently only used in Java." part, rather than making it "C# and Java"?

- ``remote`` which represents requests and responses from the network.
- ``local`` which represents data from local files (``file``), command-line arguments (``commandargs``), database reads (``database``), and environment variables(``environment``).
- ``remote`` which represents requests (``request``) and responses (``response``) from the network.
- ``local`` which represents data from local files (``file``), command-line arguments (``commandargs``), database reads (``database``), environment variables(``environment``) and Windows registry values ("windows-registry").
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not great, but I think this expresses the information you're looking for.

Suggested change
- ``local`` which represents data from local files (``file``), command-line arguments (``commandargs``), database reads (``database``), environment variables(``environment``) and Windows registry values ("windows-registry").
- ``local`` which represents data from local files (``file``), command-line arguments (``commandargs``), database reads (``database``), environment variables(``environment``) and Windows registry values ("windows-registry"). Windows registry values are used by C# only.

aeisenberg
aeisenberg previously approved these changes Jul 9, 2024
@owen-mc
Copy link
Contributor Author

owen-mc commented Jul 20, 2024

@aeisenberg Note that I've reverted one line that I had changed in the docs - it no longer explains about the subcategories response and request of remote, since no languages use those categories yet.

Copy link
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QL LGTM

@owen-mc
Copy link
Contributor Author

owen-mc commented Jul 23, 2024

I spot-checked some of the QA results and they seemed valid. In total, 469 results were lost (and 3 extra found, which I think must be unrelated), from 5,517 projects, so on average 1 alert for every 11.8 projects. (And, of course, most users are not interested in reverse DNS as a source of untrusted data.)

@owen-mc owen-mc merged commit ff8bb2b into github:main Jul 23, 2024
40 checks passed
@owen-mc owen-mc deleted the java/reverse-dns-separate-threat-model-kind branch July 23, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants